USE [RedemptoristRetreat]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Attendance_RetreatSchedule]') AND parent_object_id = OBJECT_ID(N'[dbo].[Attendance]'))
ALTER TABLE [dbo].[Attendance] DROP CONSTRAINT [FK_Attendance_RetreatSchedule]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Attendee_UserAccount]') AND parent_object_id = OBJECT_ID(N'[dbo].[Attendance]'))
ALTER TABLE [dbo].[Attendance] DROP CONSTRAINT [FK_Attendee_UserAccount]
GO

USE [RedemptoristRetreat]
GO

/****** Object:  Table [dbo].[Attendance]    Script Date: 12/01/2013 14:28:44 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Attendance]') AND type in (N'U'))
DROP TABLE [dbo].[Attendance]
GO

USE [RedemptoristRetreat]
GO

/****** Object:  Table [dbo].[Attendance]    Script Date: 12/01/2013 14:28:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Attendance](
	[attendanceId] [int] IDENTITY(1,1) NOT NULL,
	[scheduleId] [int] NOT NULL,
	[userId] [int] NOT NULL,
	[groupName] [varchar](50) NULL,
	[amountPaid] [float] NULL,
	[discountAmount] [float] NULL,
	[roomType] [char](2) NULL,
	[firstFloorRequired] [tinyint] NULL,
	[dietaryNeeds] [varchar](50) NULL,
	[comment] [varchar](250) NULL,
	[activeData] [tinyint] NULL,
	[roomAssignment] [varchar](3) NULL,
	[modifiedBy] [varchar](25) NULL,
	[modifiedTimestamp] [datetime] NULL,
 CONSTRAINT [PK_Attendee] PRIMARY KEY CLUSTERED 
(
	[attendanceId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Attendance]  WITH NOCHECK ADD  CONSTRAINT [FK_Attendance_RetreatSchedule] FOREIGN KEY([scheduleId])
REFERENCES [dbo].[RetreatSchedule] ([scheduleId])
NOT FOR REPLICATION 
GO

ALTER TABLE [dbo].[Attendance] CHECK CONSTRAINT [FK_Attendance_RetreatSchedule]
GO

ALTER TABLE [dbo].[Attendance]  WITH NOCHECK ADD  CONSTRAINT [FK_Attendee_UserAccount] FOREIGN KEY([userId])
REFERENCES [dbo].[UserAccount] ([userId])
NOT FOR REPLICATION 
GO

ALTER TABLE [dbo].[Attendance] CHECK CONSTRAINT [FK_Attendee_UserAccount]
GO

